package com.job.gaoyue.day0702;

import sun.reflect.generics.tree.FieldTypeSignature;

/**
 * @author ${高某}
 * @version 1.0
 * @since 2022-07-03 10:57:46
 */
public class secon0702 {
    public static void main(String[] args) {
        int[] arr = {20, 22, 7, 2, 14, 57, 47};
        for (int i = 0; i < arr.length - 1; i++) {
            if (arr[i] > arr[i + 1]) {
                int temp = arr[i];
                arr[i] = arr[i + 1];
                arr[i + 1] = temp;
            }
        }
        //观察
        for (int i : arr) {
            System.out.println(i + ",");
        }
        /*
        另一种排序方法
         */
        int[] brr = {20, 22, 7, 2, 14, 57, 47};
        for (int i = 0; i < brr.length; i++) {
            if (brr[0] > brr[i]) {
                int temp = brr[i];
                brr[i] = brr[0];
                brr[0] = temp;
            }
        }
        for (int i : arr) {
            System.out.println(i + "\t");
        }
    }
}